//
//  plazaTagsView.m
//  SoundPill
//
//  Created by 宋鹏鹏 on 15/5/13.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "plazaTagsView.h"
@interface plazaTagsView ()
{
    float x;
}
@end
@implementation plazaTagsView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //        [self createBackgroundView];
    }
    return self;
}
- (void)createBackgroundView
{
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
    UIVisualEffectView *visual = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    visual.frame = self.bounds;
    [self addSubview:visual];
}
- (void)createTagView:(NSArray *)tags
{
    x = 10;
    for (int i = 0; i < tags.count; i++) {
        NSString *tag = tags[i];
        self.tagLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        [_tagLabel setNumberOfLines:0];
        _tagLabel.layer.cornerRadius = 1.5;
        [_tagLabel.layer setMasksToBounds:YES];
        _tagLabel.layer.borderColor = [[UIColor colorWithWhite:0.886 alpha:0.800] CGColor];
        _tagLabel.layer.borderWidth = 0;
        _tagLabel.textAlignment = NSTextAlignmentCenter;
        _tagLabel.textColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.4];
        [self setLabelText:tag];
        _tagLabel.backgroundColor = [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:0.05];
        [self addSubview:_tagLabel];
    }
}
- (void)setLabelText:(NSString *)text{
    UIFont *font = [UIFont fontWithName:@"Arial" size:12];
    _tagLabel.font = font;
    _tagLabel.text = text;
    CGSize deSize = [_tagLabel sizeThatFits:CGSizeMake(90,30)];
    _tagLabel.frame = CGRectMake(x, 5, deSize.width + 10, 20);
    x = x + deSize.width + 11.8;
}
- (CGSize)sizeWithString:(NSString *)string font:(UIFont *)font
{
    CGRect rect = [string boundingRectWithSize:CGSizeMake(200, 40)//限制最大的宽度和高度
                                       options: NSStringDrawingUsesFontLeading//采用换行模式
                                    attributes:@{NSFontAttributeName: font}//传人的字体字典
                                       context:nil];
    
    return rect.size;
}



@end
